import http from '@/api/luch-request.js'
import {
	getUploadImageUrl as _getUploadImageUrl,
	getPublicHeader as _getPublicHeader
} from '@/api/luch-request.js'

const api = {

	getUploadImageUrl() {
		return _getUploadImageUrl()
	},

	getPublicHeader() {
		return _getPublicHeader()
	},

	// 上传图片
	uploadImage(filePath) {
		return http.upload(api.getUploadImageUrl(), {
			// #ifdef MP-ALIPAY
			fileType: 'image', // 仅支付宝小程序，且必填
			// #endif
			filePath: filePath, // 要上传文件资源的路径
			name: 'file',
			custom: {
				showLoading: true,
				mock: false,
			}
		})
	},

	// 通过经纬度获取城市位置信息
	getAddressByLngLat(longitude, latitude) {
		// https://agedmall.ejiakanghu.cn/common/locationCity
		return http.post('/common/locationCity', {
			radius: 20,
			poitype: '190000|120000',
			output: 'json',
			lng: longitude,
			lat: latitude,
		}, {
			custom: {
				showLoading: false,
				mock: false,
				responseIntercept: false,
				checkInited: false,
			}
		})
	},

	// 微信授权手机号注册/登录
	weixinLogin(data, iv, code) {
		return http.post('/wx/auth/loginByWeixin', {
			data: data,
			iv: iv,
			code: code
		}, {
			custom: {
				showLoading: true,
				mock: false,
			}
		})
	},

	// 手机号+验证码注册/登录
	mobileLogin(phone, captcha, code) {
		return http.post('/common/auth/login', {
			mobile: phone,
			captcha: captcha,
			code: code,
		}, {
			custom: {
				showLoading: true,
				mock: false,
			}
		})
	},

	// 发送手机号注册登录验证码
	getSMSCaptcha(phone) {
		return http.post('/common/auth/loginCaptcha', {
			phone: phone,
			type: 'LOGIN',
		}, {
			custom: {
				showLoading: true,
				mock: false,
			}
		})
	},

	// 个人中心获取实时用户信息
	userAccountInfo(showLoading = false) {
		return http.post('/user/info', {}, {
			custom: {
				showLoading: showLoading,
				mock: false,
			}
		})
	},

	// 获取首页月账单提示信息
	homeMonthBillNotice() {
		return http.post('/home/monthBillNotice', {}, {
			custom: {
				showLoading: false,
				mock: false,
			}
		})
	},

	// 获取落地方月账单详情信息
	monthBillDetail(data) {
		return http.post('/monthBill/monthBillDetail', data, {
			custom: {
				showLoading: false,
				mock: false,
			}
		})
	},

	// 落地方月账单确认完成对账
	monthBillConfirm(data) {
		return http.post('/monthBill/monthBillConfirm', data, {
			custom: {
				showLoading: true,
				mock: false,
			}
		})
	},

	// 获取月账单管理落地方列表
	monthBillLandedList(data) {
		return http.post('/monthBill/monthBillLandedList', data, {
			custom: {
				showLoading: false,
				mock: false,
			}
		})
	},

	// 获取落地方的月账单列表
	monthBillList(data) {
		return http.post('/monthBill/monthBillList', data, {
			custom: {
				showLoading: false,
				mock: false,
			}
		})
	},

	// 调用落地方租借统计V3版API接口
	callLandedLeaseStatApi(apiName, data = {}) {
		return http.post(`/leaseStat/v3/${apiName}`, data, {
			custom: {
				showLoading: false,
				mock: false,
			}
		})
	},

	// 调用门店管理API接口
	callStoreManagerApi(apiName, data = {}, isJson = false, showLoading = false) {
		if (isJson) {
			return http.post(`/store-manager/${apiName}`, data, {
				header: {
					'content-type': 'application/json; charset=UTF-8'
				},
				custom: {
					showLoading: showLoading,
					mock: false,
				}
			})
		} else {
			return http.post(`/store-manager/${apiName}`, data, {
				custom: {
					showLoading: showLoading,
					mock: false,
				}
			})
		}
	},

}

export default api
